package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.CurrencyExchangeRate;

public class CurrencyExchangeRateWrapper {
	
	SqlManager manager;

    public CurrencyExchangeRateWrapper() {
        manager = new SqlManager("shenqisettlement");
    }
    
    @SuppressWarnings("unchecked")
	public CurrencyExchangeRate selectBySellAndBuy(String sellCurrency, String buyCurrency) {
    	
    	CurrencyExchangeRate currencyExchangeRate = new CurrencyExchangeRate();
    	
    	HashMap<String, String> map = new HashMap<>();
    	
    	map.put("sell_currency", sellCurrency);
    	map.put("buy_currency", buyCurrency);
    	
    	List<CurrencyExchangeRate> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.CurrencyExchangeRateMapper.selectBySellAndBuy",
                        map);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("currency_exchange_rate没有数据");
		}
		else 
			currencyExchangeRate = result.get(0);
		
		return currencyExchangeRate;
    }
    
    public static void main(String[] args) {
    	CurrencyExchangeRateWrapper wrapper = new CurrencyExchangeRateWrapper();
    	Logger.debug(wrapper.selectBySellAndBuy("USD", "EUR").getExchange_rate());
    }
}
